home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / utility / utilhard / lcdaem18.lha / LCDaemon / Programmer / LCDtest / lcdtest.c < prev    next >
C/C++ Source or Header  |  1996-10-13  |  2KB  |  90 lines

  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include <signal.h>
  5. #include <proto/exec.h>
  6. #include <proto/dos.h>
  7. #include <exec/ports.h>
  8. #include <dos/dos.h>
  9. #include "lcd.h"
  10.  
  11. struct MsgPort *replyport;
  12. struct lcdmessage msg;
  13. struct lcdparams lcdpar;
  14. LONG time=100;
  15. char text[100];
  16. char message[100];
  17. struct lcdirect commands[100];
  18.  
  19. int SafePutToPort(struct lcdmessage *message,STRPTR portname){
  20.     struct MsgPort *port;
  21.     Forbid();
  22.     port=FindPort(portname);
  23.     if(port) PutMsg(port,(struct Message *)message);
  24.     Permit();
  25.     return(port?TRUE:FALSE);
  26. }
  27.  
  28. int main(int argc,char **argv){
  29.     LONG delay=100,from=0,to=256,i,j,k;
  30.     struct lcdirect *lcdir;
  31.  
  32.     signal(SIGINT,SIG_IGN);
  33.  
  34.     if((argc>=1)&&argv[1])StrToLong(argv[1],(LONG *)&from);
  35.     if((argc>=2)&&argv[2])StrToLong(argv[2],(LONG *)&to);
  36.     if((argc>=3)&&argv[3])StrToLong(argv[3],(LONG *)&delay);
  37.     if(replyport=CreateMsgPort()){
  38.         msg.lcd_Message.mn_Node.ln_Type=NT_MESSAGE;
  39.         msg.lcd_Message.mn_Length=sizeof(struct lcdmessage);
  40.         msg.lcd_Message.mn_ReplyPort=replyport;
  41.         msg.lcd_Priority=LCDPRI_APPLICATION;
  42.  
  43.         msg.lcd_Code=LCDMSG_ASKPARAMS;
  44.         msg.lcd_Data=&lcdpar;
  45.         if(SafePutToPort(&msg,lcdportname)){
  46.             WaitPort(replyport);
  47.             GetMsg(replyport);
  48.             msg.lcd_Code=LCDMSG_ALLOCATELCD;
  49.             if(SafePutToPort(&msg,lcdportname)&&(WaitPort(replyport),GetMsg(replyport),!msg.lcd_Error)){
  50.                 lcdir=commands;
  51.                 msg.lcd_Code=LCDMSG_LCDIRECT;
  52.                 msg.lcd_Data=lcdir;
  53.                 lcdir->Command=LCDCMD_CLS;
  54.                 lcdir++;
  55.                 lcdir->Command=LCDCMD_DISPLAY;
  56.                 lcdir->Data=ON;
  57.                 lcdir++;
  58.  
  59.                 for(i=from;i<to;i+=lcdpar.width*lcdpar.height){
  60.                     for(j=0;j<lcdpar.height;j++){
  61.                         lcdir->Command=LCDCMD_GOTOXY;
  62.                         lcdir->Data=(j<<16)&0xffff0000;
  63.                         lcdir++;
  64.                         for(k=0;k<lcdpar.width;k++){
  65.                             lcdir->Command=LCDCMD_DATA;
  66.                             lcdir->Data=i+j*lcdpar.width+k;
  67.                             if(lcdir->Data<256)lcdir++;
  68.                         }
  69.                     }
  70.                     lcdir->Command=LCDCMD_END;
  71.                     SafePutToPort(&msg,lcdportname);
  72.                     WaitPort(replyport);
  73.                     GetMsg(replyport);
  74.                     Delay(delay);
  75.                     lcdir=commands;
  76.                     lcdir->Command=LCDCMD_CLS;
  77.                     lcdir++;
  78.                 }
  79.  
  80.                 msg.lcd_Code=LCDMSG_FREELCD;
  81.                 SafePutToPort(&msg,lcdportname);
  82.                 WaitPort(replyport);
  83.                 GetMsg(replyport);
  84.             }
  85.         }
  86.         DeleteMsgPort(replyport);
  87.     }
  88.     return(0);
  89. }
  90.